package com.ruoyi.api.config;

import com.alibaba.nacos.api.config.ConfigType;
import com.alibaba.nacos.api.config.annotation.NacosConfigListener;
import com.alibaba.nacos.api.config.annotation.NacosConfigurationProperties;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.List;
import java.util.Map;

/**
 * https://www.cnblogs.com/neaos/p/10790528.html
 */
@Data
//@ConfigurationProperties(prefix = "my-props")
@NacosConfigurationProperties(prefix = "my-props", dataId = "apple", type = ConfigType.YAML, autoRefreshed = true)
@Configuration
@Slf4j
public class NacosDynamicConf {
    private List<String> list;


    private Map<String,String> maps;

    private Map<String,List<String>> varmaplist;

    @NacosConfigListener(dataId = "apple.my-props", timeout = 500)
    public void onChange(String newContent) throws Exception {
//        System.out.println("onChange : " + newContent);
        log.info("{}",varmaplist);
    }
}
